#include <stdio.h>
#include <string.h>
#include<stdlib.h> 
int k;
int n;
int a[10000];
int digit[10000];
void dfs(int start, int depth) 
{
    if (depth == k) 
	{
        for (int i = 0; i < k - 1; i++) 
		{
            printf("%d ", digit[i]);
        }
        printf("%d\n", digit[k - 1]);
        return;
    }
    for (int i = start; i < n; i++) 
	{
        digit[depth] = a[i];
        dfs(i + 1, depth + 1);
    }
}

int main() 
{
    char input[100];
    fgets(input, sizeof(input), stdin);
    sscanf(input, "k=%d", &k);
    fgets(input, sizeof(input), stdin);
    n = 0;
    char *token = strtok(input, " \n");
    while (token != NULL) 
	{
        a[n++] = atoi(token);
        token = strtok(NULL, " \n");
    }
    dfs(0, 0);
    return 0;
}
